package person.tavion;

import org.apache.kafka.clients.producer.ProducerConfig;

import java.util.Properties;

public class KafkaUtil {
//    public static String topicName="quickstart-events";
    public static String topicName="myTopic";
    public static Properties getProperties(TypeEnum typeEnum) {
        Properties props = new Properties();
        props.put("bootstrap.servers", "tavion.com:9092");
        System.out.println(props.get("bootstrap.servers"));
        props.put("acks", "all");
        props.setProperty("group.id", "myGroup");
        props.put("retries", 0);
        props.put("batch.size", 16384);
//        props.put("linger.ms", 1);
        props.put("buffer.memory", 33554432);
        if(typeEnum == TypeEnum.Topic){
            System.out.println(1);
        }else if(typeEnum == TypeEnum.Producer){
            props.put("linger.ms", 1);
            System.out.println(2);
        }else if(typeEnum == TypeEnum.Consumer){

//            props.put("key.deserializer", "org.apache.kafka.common.serialization.StringSerializer");
//            props.put("value.deserializer", "org.apache.kafka.common.serialization.StringSerializer");
            props.setProperty("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
            props.setProperty("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
        }
        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
//        props.put(ProducerConfig.ACKS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
        return props;
    }
}
